//
//  NSObject+ZBModel.m
//  ZBExtensionKit
//
//  Created by apple on 2018/8/10.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "NSObject+ZBModel.h"
#import "ZBJSONKit.h"

@implementation NSObject (ZBModel)
/**
 字典 -- >模型
 */
+ (id)zb_objectWithKeyValues:(id)keyValues
{
    return [ZBJSONKit zb_objectWithClass:[self class] value:keyValues];
}
+ (id _Nonnull)zb_objectWithDictionary:(NSDictionary* const _Nonnull)dictionary
{
   return [ZBJSONKit zb_objectWithClass:[self class] value:dictionary];
}

/**
 字典数组 --> 模型数组
 */
+(NSArray* _Nonnull)zb_objectArrayWithKeyValuesArray:(NSArray <NSDictionary *> *)array
{
    NSMutableArray* results = [NSMutableArray array];
    for (id value in array) {
        id obj = [ZBJSONKit zb_objectWithClass:[self class] value:value];
        [results addObject:obj];
    }
    return results;
}
/**
 模型 -- >字典.
 */
-(NSMutableDictionary* _Nonnull)zb_keyValues
{
    return [ZBJSONKit zb_keyValuesWithObject:self];
}
/**
 json字符 -- >json格式数据 .
 */
+(NSDictionary *)zb_jsonWithString:(NSString*)jsonString
{
    return [ZBJSONKit zb_jsonWithString:jsonString];
}

/**
 字典 -- >json字符 .
 */
+(NSString*)zb_keyValueToJSONString:(NSDictionary *)dict
{
    return [ZBJSONKit zb_keyValueToJSONString:dict];
}


@end
